unsigned long addr;
int rc;
+ /* How many emulations could we save if we unshadowed on stack writes? */
+ if ( seg == x86_seg_ss )
+ perfc_incrc(shadow_fault_emulate_stack);
+
rc = hvm_translate_linear_addr(
seg, offset, bytes, hvm_access_write, sh_ctxt, &addr);
if ( rc )
SHADOW_PRINTK("emulate: eip=%#lx esp=%#lx\n",
(unsigned long)regs->eip, (unsigned long)regs->esp);
- /*
- * Check whether this looks like a stack operation. If so, unshadow the
- * faulting page. We can allow this to fail: if it does fail then we
- * carry on and emulate, otherwise we bail immediately. Failure is
- * tolerated because this is only a heuristic (e.g., stack segment base
- * address is ignored).
- */
- if ( unlikely((va & PAGE_MASK) == (regs->esp & PAGE_MASK)) )
- {
- gdprintk(XENLOG_DEBUG, "guest stack is on a shadowed frame: "
- "%%esp=%#lx, cr2=%#lx, mfn=%#lx\n",
- (unsigned long)regs->esp, va, mfn_x(gmfn));
- sh_remove_shadows(v, gmfn, 0 /* thorough */, 0 /* can fail */);
- if ( !(mfn_to_page(gmfn)->count_info & PGC_page_table) )
- goto done;
- }
-
emul_ops = shadow_init_emulation(&emul_ctxt, regs);
/*
PERFCOUNTER_CPU(shadow_fault_emulate_read, "shadow_fault emulates a read")
PERFCOUNTER_CPU(shadow_fault_emulate_write, "shadow_fault emulates a write")
PERFCOUNTER_CPU(shadow_fault_emulate_failed, "shadow_fault emulator fails")
+PERFCOUNTER_CPU(shadow_fault_emulate_stack, "shadow_fault emulate stack write")
PERFCOUNTER_CPU(shadow_fault_mmio, "shadow_fault handled as mmio")
PERFCOUNTER_CPU(shadow_fault_fixed, "shadow_fault fixed fault")
PERFCOUNTER_CPU(shadow_ptwr_emulate, "shadow causes ptwr to emulate")